﻿using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2025-02-27
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// OP60盖板底座焊丝组合
    /// </summary>
    [Verify]
    [Route("business/DcOp50Record")]
    [ApiExplorerSettings(GroupName = "business")]
    public class DcOp50RecordController : BaseController
    {
        /// <summary>
        /// OP60盖板底座焊丝组合接口
        /// </summary>
        private readonly IDcOp50RecordService _DcOp50RecordService;

        public DcOp50RecordController(IDcOp50RecordService DcOp50RecordService)
        {
            _DcOp50RecordService = DcOp50RecordService;
        }

        /// <summary>
        /// 查询OP60盖板底座焊丝组合列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "dcop50record:list")]
        public IActionResult QueryDcOp50Record([FromQuery] DcOp50RecordQueryDto parm)
        {
            var response = _DcOp50RecordService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询OP60盖板底座焊丝组合详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "dcop50record:query")]
        public IActionResult GetDcOp50Record(long Id)
        {
            var response = _DcOp50RecordService.GetInfo(Id);

            var info = response.Adapt<DcOp50RecordDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加OP60盖板底座焊丝组合
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "dcop50record:add")]
        [Log(Title = "OP60盖板底座焊丝组合", BusinessType = BusinessType.INSERT)]
        public IActionResult AddDcOp50Record([FromBody] DcOp50RecordDto parm)
        {
            var modal = parm.Adapt<DcOp50Record>().ToCreate(HttpContext);

            var response = _DcOp50RecordService.AddDcOp50Record(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新OP60盖板底座焊丝组合
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "dcop50record:edit")]
        [Log(Title = "OP60盖板底座焊丝组合", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateDcOp50Record([FromBody] DcOp50RecordDto parm)
        {
            var modal = parm.Adapt<DcOp50Record>().ToUpdate(HttpContext);
            var response = _DcOp50RecordService.UpdateDcOp50Record(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除OP60盖板底座焊丝组合
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "dcop50record:delete")]
        [Log(Title = "OP60盖板底座焊丝组合", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteDcOp50Record([FromRoute] string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_DcOp50RecordService.Delete(idArr));
        }

    }
}